<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>1</button>
    <button>2</button>
    <button>3</button>
    <button>4</button>
</body>
<script>
    //1 不能重复声明
    let a=10;
    console.log(a);//10
   /*  let a=20;
    console.log(a);//Identifier 'a' has already been declared */

    //2 不存在变量提升
   /*  console.log(b); //Cannot access 'b' before initialization
    let b=3; */

    //3 块级作用域
   /*  {
        let c=13;
        console.log(c);//13
        {
           console.log(c); //Cannot access 'c' before initialization
           let c=11;
           console.log(c); //11
        }
    }
    console.log(c);//undefined */

   var btn=document.querySelectorAll('button')
    //4 循环中使用let
    for(let i=0;i<btn.length;i++){
          btn[i].onclick=function(){
              console.log(i);
          }
    }

    
</script>
</html>